package com.dc.docs._888_面试.concurrent._3_collection;

import cn.hutool.core.lang.UUID;
import com.google.common.collect.Sets;

import java.util.Set;

/**
 * Description: 集合类不安全问题_ArrayList
 * @author: gdc
 * @date: 2021/6/15
 * @version 1.0
 */
public class HashSetNotSafeDemo {

    public static void main(String[] args){
        Set<String> set = Sets.newHashSet();
        for (int i = 0; i < 100; i++) {
           new Thread(() -> {
               UUID uuid = UUID.randomUUID();
               set.add(uuid.toString());

               System.out.println(set);
           }, String.valueOf(i)).start();
        }
    }
}
